package top.fkxuexi.blogapi.modules.auth.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.fkxuexi.blogapi.core.utils.common.Page;
import top.fkxuexi.blogapi.modules.auth.dao.SysUserDAO;
import top.fkxuexi.blogapi.modules.auth.entity.SysUser;
import top.fkxuexi.blogapi.modules.auth.service.SysUserService;

import java.util.List;

/**
 * @Author blog.fkxuexi.top
 * @Gitee: https://gitee.com/smartwork/
 * @Descri: 系统用户表
 */
@Transactional
@Service
public class SysUserServiceImpl implements SysUserService {

    @Autowired
    private SysUserDAO userDAO;

    @Override
    public SysUser getUserByLoginName(String loginName) {
        return userDAO.getUserByLoginName(loginName);
    }

    /**
     * 获取用户的分页信息
     * @param index 页码
     * @param size  页面大小
     * @param nickName 昵称
     * @param phone 电话
     * @param status 1：启用，2：冻结，3：删除
     * @return 返回符合要求的用户的分页信息
     */
    @Override
    public Page list(Integer index, Integer size, String nickName, String phone,Integer status) {
        PageHelper.startPage(index,size);
        List<SysUser> list = userDAO.list(nickName,phone,status);
        Page page = Page.page(new PageInfo<>(list));
        return page;
    }
}